<?
function show_login($error) {
	global	$config;
	global	$phpEx;

	$roomlist	= getRoomList();

	$template = new Template($config['TPL_DIR']);
	$template->set_filenames(array('body' => 'transcript_query.tpl'));

	$template->assign_vars(array(
		'ROOMLIST'	=> $roomlist,
		'ERROR'		=> $error,
		'USERNAME'	=> $_REQUEST['username'],
		'PASSWORD'	=> $_REQUEST['password']
	));

	show_date_select(&$template, '1');
	show_date_select(&$template, '2');

	$template->pparse('body');
}

function show_date_select($template, $suffix) {
	$months	= array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

	$this_month	= date("M");
	$this_year	= date("Y");
	$this_date	= date("j");

	print("<!-- today is $this_month $this_date $this_year -->\n");
	foreach ($months as $m => $n) {
		$month	= $m+1;
		$sel	= '';
		if ($n == $this_month) {
			$sel	= " SELECTED";
		}
		$template->assign_block_vars("month$suffix", array(
			'VALUE'		=> $month,
			'NAME'		=> $n,
			'SELECTED'	=> $sel
		));
	}

	for ($i = 1; $i < 32; $i++) {
		$sel	= '';
		if ($i == $this_date) {
			$sel	= " SELECTED";
		}
		$template->assign_block_vars("day$suffix", array(
			'VALUE'		=> $i,
			'NAME'		=> $i,
			'SELECTED'	=> $sel
		));
	}

	for ($i = 2004; $i <= $this_year; $i++) {
		$sel	= '';
		if ($i == $this_year) {
			$sel	= " SELECTED";
		}
		$template->assign_block_vars("year$suffix", array(
			'VALUE'		=> $i,
			'NAME'		=> $i,
			'SELECTED'	=> $sel
		));
	}

	for ($i = 0; $i < 24; $i++) {
		$j	= str_pad($i, 2, "0", STR_PAD_LEFT);
		$template->assign_block_vars("hour$suffix", array(
			'VALUE'		=> $j,
			'NAME'		=> $j,
			'SELECTED'	=> ''
		));
	}

	for ($i = 0; $i < 60; $i++) {
		$j	= str_pad($i, 2, "0", STR_PAD_LEFT);
		$template->assign_block_vars("minute$suffix", array(
			'VALUE'		=> $j,
			'NAME'		=> $j,
			'SELECTED'	=> ''
		));
	}
}
